﻿using System.Collections.Generic;
using System.Linq;
using NHibernate;
using NHibernate.Linq;
using Noodles.Core.Model;
using System;
using System.Xml.Serialization;
using System.IO;
using System.Web.Hosting;

namespace Noodles.Core.Repositories
{
    public class LoginRepository : ILoginRepository
    {
        private readonly ISession session;

        public LoginRepository(ISession thissession)
        {
            session = thissession;
        }
        
        public  bool ValidateLogIn(string userID, string password)
        {
            bool isValid = false;
            var id = 0;
            try
            {
                id = session.QueryOver<UserMaster>()
                    .Where(c => c.Username == userID && c.Password == password)
                    .RowCount();

                /** Pseudo codes

                    IList<UserMaster> cats = session.QueryOver<UserMaster>().List();
                    ICriteria criteria = session.CreateCriteria(typeof(UserMaster));
                    IList<UserMaster> billi = criteria.List<UserMaster>();
                * 
                *   **/

               
                   
            }
            catch (Exception ex)
            {

            }
            if (id > 0)
            {
                isValid = true;
            }
            else
            {
                isValid = false;
            }       
            return isValid;
        }
    }
  
}
